package com.rd.student.jike.class2.lihongming.Slolution3;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Auther:Heinrich
 * @Date:2023/7/19-07-19-16:42
 * @Description:com.rd.student.jike.class2.lihongming.Solution719
 * @version:1.0
 */
public class Question4 {
    public static void main(String[] args)throws InterruptedException {
        PassCave p1 = new PassCave("张飞");
        p1.start();
        new PassCave("刘备").start();
        new PassCave("曹操").start();
        new PassCave("许褚").start();
        PassCave p5 = new PassCave("陆逊");
        p5.start();
        PassCave p6 = new PassCave("萧何");
        p6.start();
        PassCave p7 = new PassCave("刘邦");
        p7.start();
        PassCave p8 = new PassCave("王翦");
        p8.start();
        PassCave p9 = new PassCave("李牧");
        p9.start();
        PassCave p10 = new PassCave("李靖");
        p10.start();

    }

}
class PassCave extends Thread{
    long time = 1000;
    static final AtomicInteger order = new AtomicInteger(1);

    public PassCave(String name) {
        super(name);
    }

    @Override
    public void run() {

        synchronized (order) {
            //int times = Integer.parseInt(order.toString());
            try {
                Thread.sleep((long) (500));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(getName() + " 的次序为 " + order.getAndIncrement());

        }
    }
}
